package com.ruoyi.project.dentalOrder.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.dentalOrder.domain.DentalOrder;
import com.ruoyi.project.dentalOrder.service.IDentalOrderService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 产品订单Controller
 * 
 * @author wyh
 * @date 2024-08-20
 */
@RestController
@RequestMapping("/dentalOrder/dentalOrder")
public class DentalOrderController extends BaseController
{
    @Autowired
    private IDentalOrderService dentalOrderService;

    /**
     * 查询产品订单列表
     */
    @PreAuthorize("@ss.hasPermi('dentalOrder:dentalOrder:list')")
    @GetMapping("/list")
    public TableDataInfo list(DentalOrder dentalOrder)
    {
        startPage();
        List<DentalOrder> list = dentalOrderService.selectDentalOrderList(dentalOrder);
        return getDataTable(list);
    }

    /**
     * 导出产品订单列表
     */
    @PreAuthorize("@ss.hasPermi('dentalOrder:dentalOrder:export')")
    @Log(title = "产品订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DentalOrder dentalOrder)
    {
        List<DentalOrder> list = dentalOrderService.selectDentalOrderList(dentalOrder);
        ExcelUtil<DentalOrder> util = new ExcelUtil<DentalOrder>(DentalOrder.class);
        util.exportExcel(response, list, "产品订单数据");
    }

    /**
     * 获取产品订单详细信息
     */
    @PreAuthorize("@ss.hasPermi('dentalOrder:dentalOrder:query')")
    @GetMapping(value = "/{outTradeNo}")
    public AjaxResult getInfo(@PathVariable("outTradeNo") String outTradeNo)
    {
        return success(dentalOrderService.selectDentalOrderByOutTradeNo(outTradeNo));
    }

    /**
     * 新增产品订单
     */
    @PreAuthorize("@ss.hasPermi('dentalOrder:dentalOrder:add')")
    @Log(title = "产品订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DentalOrder dentalOrder)
    {
        return toAjax(dentalOrderService.insertDentalOrder(dentalOrder));
    }

    /**
     * 修改产品订单
     */
    @PreAuthorize("@ss.hasPermi('dentalOrder:dentalOrder:edit')")
    @Log(title = "产品订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DentalOrder dentalOrder)
    {
        return toAjax(dentalOrderService.updateDentalOrder(dentalOrder));
    }

    /**
     * 删除产品订单
     */
    @PreAuthorize("@ss.hasPermi('dentalOrder:dentalOrder:remove')")
    @Log(title = "产品订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{outTradeNos}")
    public AjaxResult remove(@PathVariable String[] outTradeNos)
    {
        return toAjax(dentalOrderService.deleteDentalOrderByOutTradeNos(outTradeNos));
    }
}
